package com.hcy.esArsenal.utils;

import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author huchenying
 * @Description Wrapper工具类
 * @Date 2021/8/16
 **/
@Component
public class EsWrapperCommonUtils {

    public static String coverField(String field){

        char[] chars = field.toCharArray();
        StringBuilder stringBuilder = new StringBuilder();
        for (char aChar : chars) {
            if (isUpCase(aChar)) {
                stringBuilder.append("_");
                String s = String.valueOf(aChar).toLowerCase();
                stringBuilder.append(s);
            }else {
                stringBuilder.append(aChar);
            }
        }
        return  stringBuilder.toString();
    }

    public static boolean isUpCase(char c){
        //判断是不是大写字母 65 ~ 90    97 ~ 122
        return c >= 65 && c <= 90;
    }
}
